Skip to content

Conversation

@ultmaster
Copy link
Contributor

Summary

  • add an optional port argument to Trainer that forwards to ClientServerExecutionStrategy
  • update strategy initialization to honor the trainer-level port for default, registry, and pre-built strategies
  • cover the new behavior with tests for client-server and non client-server configurations

Testing

  • pytest tests/trainer/test_trainer_init.py (fails: missing opentelemetry dependency in environment)

https://chatgpt.com/codex/tasks/task_e_68f97fa44e1c832e9ac51733bbd00cf5

Copilot AI review requested due to automatic review settings October 23, 2025 01:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an optional port parameter to the Trainer class that automatically configures the server port for client-server execution strategies. When provided, the port is forwarded to ClientServerExecutionStrategy instances, whether they are constructed by default, resolved from the registry, or provided as pre-built instances.

Key changes:

  • Added port parameter to Trainer.__init__() that forwards to client-server strategies
  • Updated _make_strategy() to apply the port to default, registry-resolved, and pre-built strategies
  • Added comprehensive test coverage for port forwarding behavior with different strategy configurations

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
agentlightning/trainer/trainer.py Added port parameter to Trainer class and updated strategy initialization to honor it
tests/trainer/test_trainer_init.py Added three test cases covering port forwarding to client-server strategies and verifying it's ignored for non-client-server strategies

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +313 to 316
if port is not None:
return ClientServerExecutionStrategy(n_runners=n_runners, server_port=port)
return ClientServerExecutionStrategy(n_runners=n_runners)

Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional logic duplicates the ClientServerExecutionStrategy instantiation. Simplify by constructing kwargs conditionally and creating the strategy once.

Suggested change
if port is not None:
return ClientServerExecutionStrategy(n_runners=n_runners, server_port=port)
return ClientServerExecutionStrategy(n_runners=n_runners)
kwargs = {"n_runners": n_runners}
if port is not None:
kwargs["server_port"] = port
return ClientServerExecutionStrategy(**kwargs)

Copilot uses AI. Check for mistakes.
@ultmaster ultmaster marked this pull request as draft October 24, 2025 17:18
@ultmaster ultmaster marked this pull request as ready for review October 24, 2025 17:18
@ultmaster ultmaster merged commit aab9765 into main Oct 24, 2025
28 checks passed
@ultmaster ultmaster deleted the codex/add-configurable-port-to-trainer branch October 28, 2025 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants